package com.mtsmda.designPattern.adapter;

public class TestAdapter {

	public static void main(String[] args) {
		getSocketClass();
		System.out.println();
		getSocketObject();
	}

	private static void getSocketClass() {
		SocketAdapterI socketAdapterClass = new SocketClassAdapterImpl();
		Volt voltDefault = getVolt(socketAdapterClass, 120);
		System.out.println(voltDefault.getVolt());

		Volt volt3 = getVolt(socketAdapterClass, 3);
		System.out.println(volt3.getVolt());

		Volt volt12 = getVolt(socketAdapterClass, 12);
		System.out.println(volt12.getVolt());

		Volt volt120 = getVolt(socketAdapterClass, 120);
		System.out.println(volt120.getVolt());
	}
	
	private static void getSocketObject() {
		SocketAdapterI socketAdapterClass = new SocketObjectAdapterImpl();
		Volt voltDefault = getVolt(socketAdapterClass, 120);
		System.out.println(voltDefault.getVolt());

		Volt volt3 = getVolt(socketAdapterClass, 3);
		System.out.println(volt3.getVolt());

		Volt volt12 = getVolt(socketAdapterClass, 12);
		System.out.println(volt12.getVolt());

		Volt volt120 = getVolt(socketAdapterClass, 120);
		System.out.println(volt120.getVolt());
	}

	private static Volt getVolt(SocketAdapterI socketAdapterI, int volt) {
		switch (volt) {
		case 3: {
			return socketAdapterI.get3Volt();
		}

		case 12: {
			return socketAdapterI.get12Volt();
		}

		case 120: {
			return socketAdapterI.get120Volt();
		}

		default: {
			return socketAdapterI.get120Volt();
		}
		}
	}

}